home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / Example Libraries / ControlPanels.vulib next >
Encoding:
Text File  |  1998-06-04  |  5.4 KB  |  185 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        ControlPanels.vulib
  3. #
  4. #    Contains:    Sample tasks for working with standard Macintosh Conrol Panels
  5. #
  6. #    Requirements:  System 7
  7. #
  8. #    Written by:    David G. Gaxiola
  9. #
  10. #    Copyright:    © 1992 by Apple Computer, Inc., all rights reserved.
  11. #
  12. #    Change History (most recent first):
  13. #
  14. #                 3/1/96     JC      Modified several of the descriptor ordinatilities in the CDEV tasks.
  15. #                 6/16/92    DGG        Created.
  16. #
  17. #    To Do:
  18. #
  19.  
  20. Libraries "QuickTasks.vulib", "UtilityTasks.vulib";
  21.  
  22. (************************************************************************************
  23. * Task MonitorsCDEV(monType := "gray")
  24. *    Will set the current monitor type, either "color" or "gray".
  25. ************************************************************************************)
  26. task MonitorsCDEV(monType := "gray")
  27. begin
  28.     taskResult := false;
  29.     if (LaunchAppInSystem7("Monitors", 6, true, true))
  30.     begin
  31.         taskResult := true;
  32.         if (monType ~= /g≈/)
  33.         begin
  34.             select [radioButton t:"Grays:" w:[window o:1 t:"Monitors"]];
  35.         end;
  36.         else if (monType ~= /c≈/)
  37.         begin    
  38.             select [radioButton t:"Colors:" w:[window o:1 t:"Monitors"]];
  39.         end;
  40.         else
  41.         begin
  42.             LogError("Unknown monitor type specified:  must be ∂"gray∂" or ∂"color∂".");
  43.             taskResult := false;
  44.         end;
  45.     end;
  46.     else
  47.     begin
  48.         LogError("Could not launch Monitors CDEV!");
  49.         taskResult := false;
  50.     end;
  51.     return taskResult;
  52. end;
  53.  
  54. (************************************************************************************
  55. * Task KeyboardCDEV()
  56. *    This task performs one action, to turn off the delay until repeat 
  57. *    characteristic.
  58. ************************************************************************************)
  59. task KeyboardCDEV()
  60. begin
  61.     if (LaunchAppInSystem7("Keyboard", 6, true, true))
  62.     begin
  63.         taskResult := true;
  64.         DoSelectRadioButton(35, "o");
  65.     end;
  66.     else
  67.     begin
  68.         taskResult := false;
  69.         LogError("Could not launch Keyboard CDEV!");
  70.     end;
  71.     return taskResult;
  72. end;
  73.  
  74. (************************************************************************************
  75. * Task HandlePossibleDialog(closeTime)
  76. *    To be used by sharingSetupCDEV ... see below.
  77. *    Will attempt to deal with any dialogs that may come up due to changing the state
  78. *    of file sharing.
  79. ************************************************************************************)
  80. task HandlePossibleDialog(closeTime := 0)
  81. begin
  82.     match [window o:1 s:?winStyle];
  83.     if (winStyle = dialog)
  84.         begin
  85.             type k:{ tabKey, closeTime };
  86.             select [button t:"OK" w:[window o:1]];
  87.         end;
  88. end;
  89.  
  90. (************************************************************************************
  91. * Task SharingSetupCDEV(setupTask, closeTime)
  92. *    Possible parameters are the strings "sharing" and "linking" which will determine
  93. *    whether the state of file sharing or program linking is toggled.  The closeTime
  94. *    variable will determine the length of time to wait until disconnecting people
  95. *    using filesharing (if any).
  96. ************************************************************************************)
  97. task SharingSetupCDEV(setupTask := "sharing", closeTime := 0)
  98. begin
  99.     if (LaunchAppInSystem7("Sharing Setup", 6, true, true))
  100.     begin    
  101.         returnCode := true;
  102.         if (setupTask ~= /s≈/)
  103.         begin
  104.             select [button o:2 w:[window o:1 t:"Sharing Setup"]];
  105.             handlePossibleDialog(CloseTime);
  106.         end;
  107.         else if (setupTask ~= /l≈/)
  108.         begin
  109.             select [button o:1 w:[window o:1 t:"Sharing Setup"]];
  110.         end;
  111.         else 
  112.         begin
  113.             LogError("Unknown action requested to be performed on Sharing Setup CDEV!");
  114.             returnCode := false;
  115.         end;
  116.     end;
  117.     else
  118.     begin
  119.         LogError("The Sharing Setup CDEV is not the top window!");
  120.         returnCode := false;
  121.     end;
  122.     return returnCode;
  123. end;
  124.  
  125. (************************************************************************************
  126. * Task ViewsCDEV(fontName, fontSize, iconView, listView, iconSize)
  127. *    Will work with the views control panel.  Custom view settings can be added.
  128. *    Just add another else clause for the listView and the iconView which specifies
  129. *    what you want done.
  130. ************************************************************************************)
  131. task ViewsCDEV(fontName := "Geneva", fontSize := "9", iconView := "default",
  132.                 listView := "default", iconSize := "small")
  133. begin
  134.     if (LaunchAppInSystem7("Views", 6, true, true))
  135.     begin
  136.         returnCode := true;
  137.         
  138.         select [menuItem t:fontName m:[popup o:16 w:[window t:'Views' o:1]]];
  139.         select [menuItem t:fontSize m:[popup o:15 w:[window t:'Views' o:1]]];
  140.  
  141.         if (listView = 'default')
  142.         begin
  143.             UnCheckBox('Calculate folder Sizes');
  144.             UnCheckBox('Show disk info in header');
  145.             DoCheckBox('Show size');
  146.             DoCheckBox('Show kind');
  147.             DoCheckBox('Show label');
  148.             DoCheckBox('Show date');
  149.             UnCheckBox('Show version');
  150.             UnCheckBox('Show comments');
  151.         end;
  152.         else if (listView = 'shownothing')
  153.         begin
  154.             allCheckBoxes := collect [checkBox w:[window o:1]];
  155.             for each singleCheckBox in allCheckBoxes
  156.                 UnCheckbox(singleCheckBox.t);
  157.         end;
  158.     
  159.         if (iconView = 'default')
  160.         begin
  161.             match [contentItem t:'Straight grid' r:?contentLocation]!;
  162.             SelectRectangle(contentLocation);
  163.             UnCheckBox('Always snap to grid');
  164.         end;
  165.         else if (iconView = 'alwayssnap')
  166.         begin
  167.             DoCheckBox('Always snap to grid');
  168.         end;
  169.     
  170.         if (iconSize = 'small')
  171.             select [radioButton o:11 w:[window o:1]];
  172.         else if (iconSize = 'medium')
  173.             select [radioButton o:10 w:[window o:1]];
  174.         else if (iconSize = 'large')
  175.             select [radioButton t:'' o:9 w:[window o:1]];
  176.     end;
  177.     else
  178.     begin
  179.         returnCode := false;
  180.         LogError("Could not launch Views CDEV!");
  181.     end;
  182.     
  183.     return returnCode;
  184. end;
  185.